<style lang="less">
  @import './login.less';
</style>

<template>
  <div class="login">
    <div class="login-con">
      <Tabs size="small">
        <TabPane label="登录">
          <login-form @on-success-valid="handleSubmit" class="login-form" ref="loginForm"></login-form>
        </TabPane>
      </Tabs>
    </div>
  </div>
</template>

<script>
import LoginForm from '_c/login-form'
import { mapActions } from 'vuex'
export default {
  components: {
    LoginForm
  },
  methods: {
    ...mapActions([
      'handleLogin'
    ]),
    handleSubmit ({ userName, password,code,keep }) {
      this.handleLogin({ userName, password,code,keep }).then(res => {
        if(res.code===0){
          this.$Notice.error({
            title: '登入失败',
            desc: res.msg
          });
          this.$refs.loginForm.refreshCode();
        }else if(res.code===1) {
          this.$router.push({
            name: this.$config.homeName
          })
        }
      })
    }
  }
}
</script>

<style>

</style>
